package com.hsnn.medstgmini.settlement.dao.impl;

import javax.annotation.Resource;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.hsnn.medstgmini.dao.HibernateSqlUtil;
import com.hsnn.medstgmini.settlement.dao.SetBankInfoDao;
import com.hsnn.medstgmini.settlement.model.SetBankInfo;

@Repository
public class SetBankInfoDaoImpl implements SetBankInfoDao {
	
	@Resource(name = "sessionFactory")
	private SessionFactory sessionFactory;
	@Autowired
	private HibernateSqlUtil dao;
	@Override
	public SetBankInfo getBankInfoByBankCode(String bankCode) {
		Session session = sessionFactory.getCurrentSession();
		StringBuffer sql = new StringBuffer();
		sql.append("select A.* from set_bankinfo A  where A.bank_code = :bankCode");
		Query query = session.createSQLQuery(sql.toString()).addEntity(SetBankInfo.class);
		query.setParameter("bankCode", bankCode);
		SetBankInfo setBankInfo = (SetBankInfo)query.uniqueResult();
		return setBankInfo;	
		
	}
}